<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件
function status($status){
	if($status == 1){
		$str = "<span class ='label label-success radius'>正常</span>";
		}elseif($status == 0){
			$str = "<span class ='label label-danger radius'>待审</span>";
			}else{
				$str = "<span class ='label label-danger radius'>删除</span>";
				}
	return $str;
	}

// @param $url
// @param int $type 0 get 1 post
// @param array $data
function doCurl($url, $type=0, $data=[]){
	$ch = curl_init(); //初始化
	//设置选项
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	
	if($type == 1){
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POST, $data);
		}
	//执行并获取内容
	$output = curl_exec($ch);
	//释放curl句柄
	curl_close($ch);
	return $output;
	
	}

//商户入驻申请状态判断
function bisRegister($status){
	if($status == 1){
		$str = "入住申请成功";
		}elseif($status == 0){
			$str = "待审核，审核后平台方会发送邮件通知，请关注邮件通知";
		}elseif($status == 2){
			$str = "非常抱歉，您提交的材料不符合条件，请重新提交";
		}else{
			$str = "该申请已被删除";
			}
	   return $str;
	}

//分页
function pagination($obj){
	if(!$obj){
		return '';
		}else{
			$params = request()->param();  //获取url中参数
			return '<div class="cl pd-5 bg-1 bk-gray mt-20 tp5-o2o">'.$obj->appends($params)->render().'</div><!--分页-->';
			}
	
	}


//获取二级城市
function getSeCityName($path){
	if(empty($path)){
		return '';
		}
	if(preg_match('/,/', $path)){
		$cityPath = explode(',', $path);
		$cityId = $cityPath[1];
		}else{
			$cityId = $path;
			}
	$city = model('City')->get($cityId);
	return $city->name;
	
	}

function getSeCityId($path){
	if(empty($path)){
		return '';
		}
	if(preg_match('/,/', $path)){
		$cityPath = explode(',', $path);
		$cityId = $cityPath[1];
		}else{
			$cityId = $path;
			}
	$city = model('City')->get($cityId);
	return $city->id;
	
	}

//获取二级分类
function getSeCategoryName($path){
	if(empty($path)){
		return '';
		}
	if(preg_match('/,/', $path)){
		$categoryPath = explode(',', $path);
		$categoryId = $categoryPath[1];
		}else{
			$categoryId = $path;
			}
	$category = model('Category')->get($categoryId);
	return $category->name;
	
	}

function getSeCategoryId($path){
	if(empty($path)){
		return '';
		}
	if(preg_match('/,/', $path)){
		$categoryPath = explode(',', $path);
		$categoryId = $categoryPath[1];
		}else{
			$categoryId = $path;
			}
	$category = model('Category')->get($categoryId);
	return $category->id;
	
	}


function countLocation($ids){

	if($ids && preg_match('/,/', $ids)){
		$arr = explode(',',$ids);
		return count($arr);
		
		}else{
			return 1;
			}
	
	
	}


//生成订单号
function setOrderSn(){
      list($t1, $t2) = explode(' ', microtime());
	 // dump(microtime());exit;
	 //echo $t1."&&".$t2;exit;
	 $t3 = explode('.', $t1*10000);
	 return $t2.$t3[0].(rand(10000,99999));

	
	
	}












